<html>
<head><meta charset="utf-8"><title>Can #[no_link] be extended to pull in types? · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html">Can #[no_link] be extended to pull in types?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="186023121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186023121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186023121">(Jan 19 2020 at 03:25)</a>:</h4>
<p>There's a <code>#[no_link]</code> attribute that you can put on an <code>extern crate foo;</code> statement to declare that you don't want to link against an extern crate.</p>
<p>This is, according to the notes in the reference, intended so that you can use macros from that crate. However, I wonder if we can expand the attribute so that it also pulls in types from that crate? They're just aliases after all, you're not linking in any actual code by using them.</p>
<p>Playground example of the desired possible usage: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=bc74ec6092c6ab838922555a773044d9" target="_blank" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=bc74ec6092c6ab838922555a773044d9">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=bc74ec6092c6ab838922555a773044d9</a></p>



<a name="186023407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186023407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186023407">(Jan 19 2020 at 03:35)</a>:</h4>
<p>(Out of interest, is there a reason this is an attribute, and not default behavior?)</p>



<a name="186033423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186033423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186033423">(Jan 19 2020 at 09:34)</a>:</h4>
<p>other than backward compatibility, you mean? for example, linking a crate can pull in #[no_mangle] symbols or native libraries that other parts of the application need, without that connection being apparent to rustc</p>



<a name="186039445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186039445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186039445">(Jan 19 2020 at 12:55)</a>:</h4>
<p>Hm, I guess it does depend, sometimes you want linkage and sometimes you don't.</p>



<a name="186043169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186043169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186043169">(Jan 19 2020 at 14:54)</a>:</h4>
<p>Yeah. Arguably the default should have been different but, you know, backwards compatibility</p>



<a name="186098301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186098301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186098301">(Jan 20 2020 at 12:44)</a>:</h4>
<p>Notice that <code>extern crate foo;</code> does not link anything</p>



<a name="186098312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186098312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186098312">(Jan 20 2020 at 12:45)</a>:</h4>
<p>You have to actually go and use something from the <code>foo</code> crate</p>



<a name="186098344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186098344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186098344">(Jan 20 2020 at 12:45)</a>:</h4>
<p>since otherwise the crate is marked as "unused" and it will be removed early on</p>



<a name="186098409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186098409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186098409">(Jan 20 2020 at 12:46)</a>:</h4>
<p>(e.g. <code>extern crate jemallocator_global;</code> does not override the <code>#[global_allocator]</code> for this reason)</p>



<a name="186098421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186098421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186098421">(Jan 20 2020 at 12:46)</a>:</h4>
<p>(that crate only contains a <code>#[global_allocator]</code> declaration)</p>



<a name="186147922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186147922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186147922">(Jan 21 2020 at 02:37)</a>:</h4>
<p>Hm, I guess it does depend, sometimes you want linkage and sometimes you don't.</p>



<a name="186269978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Can%20%23%5Bno_link%5D%20be%20extended%20to%20pull%20in%20types%3F/near/186269978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Can.20.23.5Bno_link.5D.20be.20extended.20to.20pull.20in.20types.3F.html#186269978">(Jan 22 2020 at 09:43)</a>:</h4>
<p>usually, when the crate you have as a dependency contains something "global", like builtins, <code>#[global_allocator]</code>, <code>panic</code>-related functionality, etc. you want it linked</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>